<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<div align="center" style="font-family:굴림;font-size:22pt;font-weight: bold">
<img src="<%=request.getContextPath() %>/image/left.JPG" width="20" height="20">
${p_name }
<img src="<%=request.getContextPath() %>/image/right.JPG"  width="20" height="20">
</div>
<div style="font-family:굴림;font-size:9pt">
입력상자를 클릭하면 달력이 나타나고 날짜를 클릭하면 날짜가 입력됩니다. 입력하지 않으면 오늘로 계산됩니다.<br>
직접입력할 때는 양식을 맞춰서 적어주세요 (ex 2013-12-25)
</div>


<!-- 날짜로 검색 -->
<form action="phistorylist.do" method="post" onsubmit="checkDate()">
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr><td colspan="3"><hr size="1" width="100%" noshade="noshade"></td></tr>
<tr>
<input type="hidden" name="p_num" value="${p_num }">
<input type="hidden" name="p_name" value="${p_name }">
<td width="40%">
시작날짜 : <input type="text" id="target_date" name="target_date"><input type="button" value="달력" onClick="datePicker(event,'target_date')">
</td>
<td width="40%">
마지막날짜 : <input type="text" id="target_date1" name="target_date1"><input type="button" value="달력" onClick="datePicker(event,'target_date1')">
</td>
<td align="right">
<input type="submit" value="검색">
</td>
</tr>
<tr><td colspan="3"><hr size="1" width="100%" noshade="noshade"></td></tr>
</table>
</form>

<!-- 주차장번호를 토대로 해당 주차장만 출력할껀데 그 주차장번호로 주차장 이름을 가져옴 -->
<table width="100%" border="0" cellspacing="1" cellpadding="2">
	<tr>
		<td colspan="9" align="left">남은 주차공간 : <font color="red" style="font-weight: bold">${space }</font>대 가능</td>
		<td>
			<c:if test="${space > 0 }">
				<input type="button" value="차량진입" onclick="location.href='pHistoryInsert.do?p_num=${p_num}'" style="width: 120px;height: 22px;">
			</c:if>
			<c:if test="${space == 0 }">
				<input type="button" value="차량진입불가" style="width: 120px;height: 22px;background-color: gray" disabled>
			</c:if>
		</td>
	</tr>
	<tr bgcolor="#d3d3d3">
		<th width="5%">번호</th>
		<th width="10%">차종</th>
		<th width="10%">차번호</th>
		<th width="10%">차주이름</th>
		<th width="10%">전화번호</th>
		<th width="15%">출입시간</th>
		<th width="15%">나간시간</th>
		<th width="5%">총주차</th>
		<th width="5%">총금액</th>
		<th width="2%">버튼</th>
	</tr>
	<c:forEach var="history" items="${phList }" varStatus="status">
	<tr>
			<td align="center">${status.index+1}</td>
			<td>${history.ph_model }</td>
			<td>${history.ph_plate }</td>
			<td>${history.ph_name }</td>
			<td>${history.ph_phone }</td>
			<%-- <td><fmt:formatDate value="${history.ph_enterTime}" pattern="yyyy-MM-dd KK:mm:ss"/></td> --%>
			<td align="center">${history.ph_enterTime }</td>
			<td align="center">${history.ph_exitTime }</td>
			<td align="right"><c:if test="${not empty history.ph_totalTime }">${history.ph_totalTime }분</c:if></td>
			<td align="right"><c:if test="${not empty history.ph_totalTime }">${history.ph_amount }원</c:if></td>
			<td>
			<c:if test="${empty history.ph_exitTime }">
				<input type="button" value="차량나감" onclick="return exitCheck(${history.ph_num})" style="width: 120px;height: 22px">
			</c:if>
			<c:if test="${!empty history.ph_exitTime }">
				<input type="button" value="기록삭제" onclick="return deleteCheck(${history.ph_num})" style="width: 120px;height: 22px">
			</c:if>
			</td>
		</tr>
	</c:forEach>
	<tr style="background-color: #CEFBC9">
		<td colspan="8" align="center"><font style="font-weight: bold;">총매출</font></td>
		<td align="right"><font style="font-weight: bold;">${amount }원</font></td>
		<td></td>
	</tr>
</table>